package ibmetp.mis.controller.sysparam;

import ibmetp.mis.common.Constants;
import ibmetp.mis.service.PageService;
import ibmetp.mis.serviceImpl.RoleServiceImpl;
import ibmetp.mis.serviceImpl.SysParamServiceImpl;
import ibmetp.mis.serviceImpl.UserServiceImpl;
import ibmetp.mis.vo.Page;
import ibmetp.mis.vo.SysParam;


import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import net.sf.json.JSONObject;

/**
 * Servlet implementation class SysParamPageServlet
 * 获取一页的角色列表
 * @author ZHANG YU TING
 * @created 2011-10-6
 */
public class SysParamPageServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public SysParamPageServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#service(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		request.setCharacterEncoding(Constants.ENCODING_UTF8);
		//当前页号
		int pageNo=request.getParameter("page")!=null?Integer.parseInt(request.getParameter("page")):1;
		System.out.println("pageNo:"+pageNo);
		
		//页面大小
		int pageSize=request.getParameter("rows")!=null?Integer.parseInt(request.getParameter("rows")):2;
		System.out.println("pageSize:"+pageSize);
		
		//查询条件SysParam
		SysParam sysparam=new SysParam();
		//sysparam.setSysparamId(Long.valueOf(request.getParameter("SysparamId")));
		sysparam.setSysparamName(request.getParameter("paramName"));
		//System.out.println("SearchConditions:"+role);
		
		//查询数据
		PageService us=new SysParamServiceImpl();
		Page p=us.getPage(pageNo, pageSize, sysparam);	   
		
		//输出JSON数据
		JSONObject o=new JSONObject();
		o.put("rows",p.getList());
		o.put("total",p.getTotal());
		response.setCharacterEncoding(Constants.ENCODING_UTF8);
		response.getWriter().write(o.toString());
		
		
	}

}
